package com.apes.hr.salary.rewardPunish.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.hr.salary.rewardPunish.model.RewardPunishType;
import com.apes.scm.masterdata.party.model.PartyRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author HuJianLin
 * @create 2018-05-09 16:07
 */
public interface RewardPunishTypeRepository extends CustomRepository<RewardPunishType, String>{

    @Query("SELECT T FROM RewardPunishType T WHERE 1 = 1 and state ='approve'and company in (:orgIds) and (id like %:id% or quota like %:value%) ")
    Page<RewardPunishType> find(@Param("id") String id, @Param("value") String value, @Param("orgIds") List<PartyRole> orgIds, Pageable pageable);

    @Query(value = "SELECT T.* FROM hr_reward_punish_type T WHERE t.syn_interface is not null and t.validity_end_date > SYSDATE and t.state != 'delete'",nativeQuery = true)
    List<RewardPunishType> findBySynInterface();

}
